import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

import '../../common/index.dart';

class TimePage extends StatefulWidget {
  const TimePage({super.key});

  @override
  State<TimePage> createState() => _TimePageState();
}

class _TimePageState extends State<TimePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage(MyImages.timeBg),
            fit: BoxFit.fill,
          ),
        ),
        child: SafeArea(
          top: false,
          bottom: false,
          child: Stack(
            children: [
              Positioned(
                right: 10.w,
                top: 50.h,
                child: GestureDetector(
                  onTap: () {
                    context.navigateTo(AppRoutes.timeCapsuleSent);
                  },
                  child: Text(
                    'My Sent Letters',
                    textAlign: TextAlign.center,
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 13.sp,
                      fontFamily: 'PingFang',
                      fontWeight: FontWeight.w600,
                      decoration: TextDecoration.underline,
                      decorationColor: Colors.white,
                      decorationThickness: 0.75.w,
                    ),
                  ),
                ),
              ),
              Positioned(
                left: 124.w,
                top: 167.h,
                child: Text(
                  'Time Capsule',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 24.sp,
                    fontFamily: 'Port',
                    fontWeight: FontWeight.w400,
                    height: 0.83,
                  ),
                ),
              ),
              Positioned(
                left: 50.w,
                top: 235.h,
                child: SizedBox(
                  width: 275.w,
                  child: Column(
                    children: [
                      Text(
                        'Record your current feelings, dreams, or hopes for the future and place them into a time capsule. Set an unlock date and wait for your future self to open this special surprise.',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          color: Colors.black,
                          fontSize: 16.sp,
                          fontFamily: 'ReenieBeanie',
                          fontWeight: FontWeight.w500,
                        ),
                      ),
                      Text.rich(
                        textAlign: TextAlign.center,
                        TextSpan(
                          children: [
                            TextSpan(
                              text:
                                  'Set an Unlock Time: Choose to unlock after 1 month, 6 months, or even further into the future, letting time preserve your memories.Feel the Growth: When the capsule is opened, those moments of effort and inspiration will touch your heart once again.',
                              style: TextStyle(
                                color: Colors.black,
                                fontSize: 16.sp,
                                fontFamily: 'ReenieBeanie',
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                          ],
                        ),
                      ),
                      SizedBox(height: 50.h),
                      GestureDetector(
                        onTap: () {
                          if (UserService.getCurrentUser() == null) {
                            // 提示登录 
                            ScaffoldMessenger.of(context).showSnackBar(
                              const SnackBar(content: Text('Please login first')),
                            );
                          } else {
                            context.navigateTo(AppRoutes.timeCapsule);
                          }
                        },
                        child: Container(
                          width: 126.w,
                          height: 46.h,
                          decoration: ShapeDecoration(
                            color: Colors.black,
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(100.r),
                            ),
                          ),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              SvgPicture.asset(
                                MyIcons.start,
                                width: 24.w,
                                height: 24.h,
                              ),
                              Text(
                                'Start',
                                textAlign: TextAlign.center,
                                style: TextStyle(
                                  color: const Color(0xFFFF9400),
                                  fontSize: 26.sp,
                                  fontFamily: 'ReenieBeanie',
                                  fontWeight: FontWeight.w500,
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
